// miniprogram/pages/movementInfo/movementInfo.js
const db = wx.cloud.database();
const app = getApp();
const movement = db.collection('movements')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: '',
    help: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.id
    })
    try {
      db.collection('profHelp').where({
        _id: options.id
      }).get().then(res => {
        this.setData({
          help: res.data[0]
        })
        wx.setNavigationBarTitle({
          title: '求助详情',
        })
      })
    } catch (error) {
      console.log(error)
    }
  },

  onPicture: function (event) {
    console.log(event)
    wx.previewImage({
      urls: event.currentTarget.dataset.pic // 需要预览的图片http链接列表
    })
  },

  onChat: function (event) {
    wx.navigateTo({
      url: '../anonymousChat/index?id=' + event.currentTarget.dataset.id + '&name=' + event.currentTarget.dataset.name
    })
  },

  copyText:function(e){
    wx.setClipboardData({
      data: e.currentTarget.dataset.text,
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            wx.showToast({
              title: '复制成功'
            })
          }
        })
      }
    })
  }
})